package test_interface

import "fmt"

type ITest interface {
	test() string
}

type Robot struct {
	name   string
	height int
}

func (s *Robot) test() string {
	fmt.Printf("robot %s is tested.\n", s.name)
	return "it's ok"
}

type People struct {
	name string
	sex  int
}

func (s *People) test() string {
	fmt.Printf("people %s is tested.\n", s.name)
	return "it's ok"
}

func Do() {
	fmt.Println("接口测试")
	var robot ITest
	robot = &Robot{name: "A11", height: 10}
	doTest(&robot)
	robot = &People{name: "P99", sex: 1}
	doTest(&robot)
}

func doTest(testObj *ITest) {
	(*testObj).test()
}
